<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提交出金申请</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>

<body>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">

                <div class="ibox-title">
                    <h3>资金管理 ><small class="m-l-sm">出金申请</small></h3>
                </div>
                <div class="ibox-content" style="background-color:#edf1f2;height: 200px;" >
                    <div class="list-group">{$set.remarks}</div>
                </div>

                <form action="" method="post" class="form form-horizontal" id="form_gold_add">
                    <div class="form-group" style="margin-top: 50px;">
                        <label class="col-sm-3 control-label">现有余额：</label>
                        <div class="col-sm-4" style="width: 100px;">
                            <label class="col-sm-1 control-label">{$balance.balance|round=###,2}</label>
                        </div>

                        <label class="col-sm-1 control-label" style="text-align: left;width:9%;">正出金金额：</label>
                        <div class="col-sm-4" style="width: 100px;">
                             <label class="col-sm-1 control-label" style="text-align: left">{$gold}</label>
                        </div>

                        <label class="col-sm-1 control-label" style="text-align: left">可用金额：</label>
                        <div class="col-sm-4" style="width: 100px;">
                            <label class="col-sm-1 control-label" style="text-align: left">{$available}</label>
                        </div>

                        <!--<label class="col-sm-1 control-label" style="text-align: left;">预计下期收益：</label>
                        <div class="col-sm-4" style="width: 380px;">
                            <label class="control-label" style="text-align: left;width:100%;">{$balance.balanceAir1|round=###,2} 元 人民币 --- {$balance.balanceAir2|round=###,2} 元 人民币</label>
                        </div>-->
                    </div>


                    <div class="form-group">
                        <label class="col-sm-3 control-label">出金账号：</label>
                        <div class="col-sm-4">
                            <select class="form-control" style="height: 32px;" name="mt4" id="mt4">
                                <option value="{$user.user_id}">{$user.user_id}</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">姓名：</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input type="text" value="{$user.name_zh_cn}" id="user_name"  name="user_name" disabled class="form-control" />
                                <span class="input-group-btn">
                                    <a type="button" id="my_bank" href="__MODULE__/Capital/bank_list/id/{$user.user_id}" class="btn btn-primary">我的银行卡</a>
                                </span>
                            </div>
                        </div>
                    </div>

                    <!--<div class="form-group">
                        <label class="col-sm-3 control-label">验证：</label>
                        <div class="col-sm-4">
                            <div class="input-group">
                                <input type="text" value="{$user.user_email}" id="very_type"  name="very_type" disabled class="form-control">

                                <span class="input-group-btn">
                                    <input type="button" id="send" class="btn btn-primary" value="发送" />
                                </span>
                            </div>
                            <!--<a id="switch" style="float: left">使用手机号验证</a>--
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-sm-3 control-label">验证码：</label>
                        <div class="col-sm-4">
                            <input type="text"  class="form-control" maxlength="6" name="verify" id="verify" placeholder="验证码">
                        </div>
                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="verify_alert" style="color: red;" ></label>
                        </div>
                    </div>-->


                    <div class="form-group" >
                        <label class="col-sm-3 control-label">持卡人姓名：</label>
                        <div class="col-sm-4">
                            <input type="text"  class="form-control" value="{$bank_data.user_name}" name="bank_user_name" id="bank_username" placeholder="持卡人姓名" maxlength="5">
                        </div>
                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="bankname_alert" style="color: red;" ></label>
                        </div>
                    </div>

                    <div class="form-group" >
                        <label class="col-sm-3 control-label">卡号：</label>
                        <div class="col-sm-4">
                            <input type="number"  class="form-control" value="{$bank_data.bank_number}" name="bank_number" id="bank_number" placeholder="银行卡卡号">
                        </div>
                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="bank_number_alert" style="color: red;" ></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">开户行：</label>
                        <div class="col-sm-4">
                            <select class="form-control" style="height: 32px;" name="bank" id="bank">
                                <foreach name="bank_list" item="ba">
                                    <option value="{$ba.name}" <if condition="$bank_data['bank_name'] eq $ba['name']">selected="selected"</if>>{$ba.name}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-sm-3 control-label">支行：</label>
                        <div class="col-sm-4">
                            <input type="text"  class="form-control"  value="{$bank_data.bank_branch}" name="bank_zhi" id="bank_zhi" placeholder="支行名称">
                        </div>
                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="bank_zhi_alert" style="color: red;" ></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所在地：</label>
                        <div class="col-sm-2">
                            <select class="form-control" style="height: 32px;" name="adds" id="adds">
                                <option value="">请选择</option>
                                <foreach name="adds" item="a">
                                    <option value="{$a.name}" <if condition="$bank_data['bank_adds'] eq $a['name']">selected="selected"</if>>{$a.name}</option>
                                </foreach>
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <select class="form-control" style="height: 32px;" name="city" id="city">
                                <if condition="$bank_data['bank_city'] neq null">
                                    <option value="{$bank_data['bank_city']}">{$bank_data['bank_city']}</option>
                                    <else/>
                                    <option value="">请选择</option>
                                </if>

                            </select>
                        </div>

                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="adds_alert" style="color: red;"></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">出金金额：</label>
                        <div class="col-sm-2 ">
                            <div class="input-group">
                                <input type="number" class="form-control" name="usd" id="usd" placeholder="美元" required="">
                                <span class="input-group-addon"><i class="fa fa-dollar"></i></span>
                            </div>
                        </div>
                        <div class="col-sm-2 ">
                            <div class="input-group">
                                <input type="number" class="form-control" name="rmb" id="rmb" placeholder="人民币" disabled>
                                <span class="input-group-addon"><i class="fa fa-jpy"></i></span>
                            </div>
                        </div>

                        <div class="col-sm-4 ng-scope">
                            <label class="help-block m-b-none" id="gold_alert" style="color: red;" ></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label pr15 ng-scope">手续费及到账</label>
                        <div class="col-sm-2">
                            <div class="input-group">
                                <input type="number"  class="form-control" name="fee" id="fee" placeholder="美元" disabled>
                                <span class="input-group-addon"><i class="fa fa-dollar"></i></span>
                            </div>
                        </div>

                        <div class="col-sm-2">
                            <div class="input-group">
                                <input type="text" class="form-control" id="Arrival" name="Arrival" placeholder="实际到账"  disabled>
                                <span class="input-group-addon"><i class="fa fa-jpy"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="row cl">
                        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                            <button type="button" class="btn btn-w-m btn-success"  id="admin-gold-add" name="admin-role-save">
                                <i class="icon-ok"></i> 提交申请
                            </button>

                            <button type="reset" style="margin-left: 20px;" href="group.html" class="btn btn-w-m btn-primary">
                                <i class="icon-ok"></i> 取消
                            </button>
                        </div>
                    </div>
                </form>
                </div>
            </div>
        </div>
</div>


<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->

<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>
<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });
    /*我的银行卡*/
    $(document).ready(function () {
        $("#my_bank").on('click',function () {
            var index = layer.load(0, {shade: false});
        });
        var submit1 = false;var submit2 = false;
        var balance = {$available};
        var adds = $("#adds").val();
        $("#adds").change(function () {
            var adds = $("#adds").val();
           if(adds){
               $.ajax({
                   type:"POST",
                   url:"__MODULE__/Capital/region",
                   dataType:'json',
                   data:{name:adds},
                   success:function(data){
                       if(data.status==1){
                           var city ='';
                           for(var i=0;i<data.msg.length;i++){
                               city +=  '<option value='+data.msg[i].id+'>'+data.msg[i].name+'</option>';
                           }
                           $("#city").html(city);$("#adds_alert").html("");
                       }else{
                           layer.error(data.error);
                       }
                   },error:function(err){
                       layer.close(index);
                       layer.msg('error:网络错误',{icon: 2, time: 2000});
                   }
               });

           }else{
               $("#city").html("<option value=''>请选择</option>");
               $("#adds_alert").html("必填");
           }
        });
        $('#usd').bind('input propertychange', function() {
            var rate = '{$set.rate}'; var max_fee = '{$set.max_fee}';
            var fee  = '{$set.fee}';
            $('#rmb').val(($(this).val()*rate).toFixed(2));
            var fees = ($(this).val()*fee).toFixed(2);
            if(max_fee=='' || max_fee==0){
                $('#fee').val(($(this).val()*fee).toFixed(2));
                $('#Arrival').val((($(this).val() - fees)*rate).toFixed(2));
            }else if(($(this).val()- max_fee) <1){
                $('#fee').val(($(this).val()*fee).toFixed(2));
                $('#Arrival').val((($(this).val() - fees)*rate).toFixed(2));
            }else{
                $('#fee').val(max_fee);
                $('#Arrival').val((($(this).val() - max_fee)*rate).toFixed(2));
            }
        });

        $("#usd").bind('mouseout',function () {
            var data = $("#usd").val();
            var  min_into= {$set.min_into};
			var max={$set.max_into};
            if(data==''){
                $("#gold_alert").html("必填");
            }else if(data < min_into){
                $("#gold_alert").html("最低提现"+ min_into+"个");
			}else if(data>max){
				 $("#gold_alert").html("最高提现"+ max+"个");
            }else if(data > balance){
                $("#gold_alert").html("提现数额不得高于可用数额");
            }else{
                $("#gold_alert").html("");
                submit1 =true;
            }
        });
        $("#switch").on('click',function () {       //switch-切换
           /* var now =  $("#very_type").val();
            var phone = '{$user.user_phone}';
            var email = '{$user.user_email}';
            if(now==''||phone==''||email==''){
                layer.msg("error");return;
            }else if(now==email){
                $("#very_type").val(phone);
                $("#switch").html("使用邮箱验证");
            }else{
                $("#very_type").val(email);
                $("#switch").html("使用手机号验证");
            }*/
            });

        $("#send").on('click',function () {         //send--发送
            var index = layer.load(0, {shade: false});
            var count =100;
            var countdown = setInterval(CountDown, 1000);
            function CountDown() {
                $("#send").attr("disabled", true);
                $("#send").val(count + " 秒后重新发送");
                if (count == 0) {$("#send").val("重新发送").removeAttr("disabled");
                    clearInterval(countdown);}count--;
            }
            var data = $("#very_type").val();
            if(data){
                $.ajax({
                    type:"POST",
                    url:"__MODULE__/MyAccount/very_send",
                    dataType:'json',
                    data:{data:data},
                    success:function(data){
                        layer.close(index);
                        if(data.status==1){
                            layer.msg(data.msg);
                        }else{
                            layer.error(data.error);
                        }
                    },error:function(err){
                        layer.close(index);
                        layer.msg('error:网络错误',{icon: 2, time: 2000});
                    }
                });
            }
        });
        $('#verify').bind('mouseout',function() {
            var very =  $(this).val();
            if(very){
                $.ajax({
                    type:"POST",
                    url:"__MODULE__/MyAccount/Verification",
                    dataType:'json',
                    data:{very:very},
                    success:function(data){
                        if(data.status==1){
                            $("#verify").css("border-color","#23b7e5");
                            $("#verify_alert").html('');submit2 = true;
                        }else{
                            $("#verify_alert").html(data.error);
                        }
                    },error:function(err){
                        layer.msg('error:网络错误',{icon: 2, time: 2000});
                    }
                });
            }else {
                $("#verify_alert").html('必填');
            }
        });

        $("#bank_username").bind('mouseout',function () {
            var bank_username=$("#bank_username").val();
            if(bank_username==''){
                $("#bankname_alert").html("必填");
            }else{
                $("#bankname_alert").html("");
            }
        });
        $("#bank_number").bind('mouseout',function () {
            var bank_number = $("#bank_number").val();
            if(bank_number==''){
                $("#bank_number_alert").html("必填");
            }else{
                $("#bank_number_alert").html("");
            }
        });
        $("#bank_zhi").bind('mouseout',function () {
            var bank_zhi=$("#bank_zhi").val();
            if(bank_zhi==''){
                $("#bank_zhi_alert").html("必填");
            }else{
                $("#bank_zhi_alert").html("");
            }
        });

        $("#admin-gold-add").on('click',function () {
           var zhi =  $("#bank_zhi").val();
           var bank_number = $("#bank_number").val();
           var bank_username = $("#bank_username").val();
           var adds = $("#adds").val();
            if(submit1 &&　zhi &&　bank_number &&　bank_username &&　adds){
                var index = layer.load(0, {shade: false});
                var params = $("#form_gold_add").serialize();
                $.ajax({
                    type : "POST",
                    url : '__MODULE__/Capital/Gold_Add_Apply',
                    data : params,
                    success : function(data) {
					console.log(data);
                        layer.close(index);
                        if(data.status==1){
                           layer.msg(data.msg);setTimeout(function () {location.reload();}, 1000);
                        }else{
                            layer.msg(data.error);setTimeout(function () {location.reload();}, 1000);
                        }
                    },error: function (err) {
                        layer.msg('网络错误');
                    }
                });
            }else{
                layer.msg("请确保信息正确完整");
            }
        })
    })

</script>
</body>
</html>
